﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HFController;
using System.Web.Script.Serialization;
using System.Web.SessionState;
namespace HFWebApp.AjaxSource
{
    /// <summary>
    /// LawyerReg 的摘要说明
    /// </summary>
    public class LawyerReg : IHttpHandler, IRequiresSessionState
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            BagePages bp = new BagePages();
            string uid = bp.GetAll("uid");
            string pwd = bp.GetAll("pwd");
            string pwd2 = bp.GetAll("pwd2");
            string realname = bp.GetAll("realname");
            string bdate = bp.GetAll("bdate");
            string email = bp.GetAll("email");
            string phone = bp.GetAll("phone");
            string mobile = bp.GetAll("mobile");
            string provinceid = bp.GetAll("provinceid");
            string cityid = bp.GetAll("cityid");
            string address = bp.GetAll("address");
            string post = bp.GetAll("post");
            string fax = bp.GetAll("fax");
            string website = bp.GetAll("website");
            string lawyerno = bp.GetAll("lawyerno");
            string lawyerfirm = bp.GetAll("lawyerfirm");
            string language = bp.GetAll("language");
            string content = bp.GetAll("content");
            string areas = bp.GetAll("areas").Replace("|",",");
            string sex = bp.GetAll("sex");

            HFModel.ResultModel result = LawyerController.getController().doAdminAddLawyer_ForAjax(uid, pwd, int.Parse(provinceid), int.Parse(cityid), int.Parse(sex), DateTime.Parse(bdate), email, phone, mobile, address, fax, post, website, realname, areas, language, content, lawyerno, lawyerfirm, "", 0, 0, 0, 0);
            if (result.isTrue)
            {
                result.goUrl = bp.getDemain + "/lawyeruser/lawyercenter.aspx";
            }
            context.Response.Write(this.getJSONResult(result));
            context.Response.End();
        }

        protected string getJSONResult(HFModel.ResultModel result)
        {
            JavaScriptSerializer jsSerializer = new JavaScriptSerializer(new SimpleTypeResolver());
            return jsSerializer.Serialize(result);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}